package com.eningqu.aipen.logic.network;

import com.eningqu.aipen.utils.GlobalConfig;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Package:com.eningqu.aipen.network
 * Author:starr
 * Time:2023/10/3  20:57
 * Description: 基础业务网络请求封装类
 */
public class BaseRetrofitUtils {
    private static volatile Retrofit retrofit = null;

    public static Retrofit getInstance() {

        if (retrofit == null) {
            synchronized (BaseRetrofitUtils.class) {
                if (retrofit == null) {

                    retrofit = new Retrofit.Builder()
                            .baseUrl(GlobalConfig.getTestServerUrl())
                            .addConverterFactory(GsonConverterFactory.create())
                            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                            .client(ShareOkHttpClient.getClient())
                            .build();
                    return retrofit;
                }
            }
        }
        return retrofit;
    }
}
